package com.lb.design.pattern.observer.gper;

import com.google.common.eventbus.EventBus;

/**
 * @author lb
 * @Title: GperTest
 * @Description: 提问、发布推送
 * @date 2019/03/19  18:51
 */
public class GperTest {
    public static void main(String[] args) {

        Question question = new Question();
        question.setUserName("GP15973");
        question.setContent("观察者设计模式适用于哪些场景？");
        //初始化消息总线
        EventBus eventBus = new EventBus();
        Teacher listener1 = new Teacher("Tom");
        Teacher listener2 = new Teacher("Mic");

        //@tom老师
        eventBus.register(listener1);
        //@Mic老师
        eventBus.register(listener2);
        // Event推送给订阅者
        eventBus.post(new Gper(question));
    }
}
